home *** CD-ROM | disk | FTP | other *** search
- /*================================================================================
- testReportError.c
-
- A simple test of the 'ReportError' package
- ================================================================================*/
- #include "reportError.h"
-
- #ifndef __FAILUREHANDLER__
- #include "FailureHandler.h"
- #endif
- #ifndef __SHOWSTACKCHAIN__
- #include "ShowStackChain.h"
- #endif
-
- /*
- // Macintosh includes
- */
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- /*
- //#ifndef __SYSEQU__
- // #include <SysEqu.h>
- //#endif
- */
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- void InitAll(void);
- Handle TryToGetMemory(void);
- void TestReportError(void);
-
- /*--------------------------------------------------------------------------------
- Initialize all of the relivant Macintosh managers
- --------------------------------------------------------------------------------*/
- void InitAll()
- {
- MaxApplZone();
-
- InitGraf( &(qd.thePort) );
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
-
- InitCursor();
- }
-
-
- /*--------------------------------------------------------------------------------
- Test the failure handler
- --------------------------------------------------------------------------------*/
- Handle TryToGetMemory()
- {
- Handle testHandle = nil;
-
- testHandle = NewHandle( 0x7FFFFFFF );
- FailMemError();
-
- return testHandle;
- }
-
-
- /*--------------------------------------------------------------------------------
- Test the report error dialog box
- --------------------------------------------------------------------------------*/
- void TestReportError()
- {
- Handle testHandle = nil;
-
- TRY
- {
- testHandle = TryToGetMemory();
- }
- EXCEPT
- {
- ReportError( (unsigned char*)"\pThe memory block could not be allocated", TheFailError() );
- }
- ENDTRY
- }
-
-
- /*--------------------------------------------------------------------------------
- A short test of 'ReportError'
- --------------------------------------------------------------------------------*/
- main()
- {
- InitAll();
- InitShowStackChain();
- TestReportError();
- }
-